package com.fanfan.SmartPensionSystembackend.mapper;

import com.fanfan.SmartPensionSystembackend.entity.Activity;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Description ActivityMapper
 * @Author Guangdi Chen
 * @Date 2025-03-23
 */
@Mapper
public interface ActivityMapper {
    // 添加活动
    @Insert("INSERT INTO activity (activityDate, name, location, content, status, participants) " +
            "VALUES (#{activityDate}, #{name}, #{location}, #{content}, #{status}, #{participants})")
    boolean insertActivity(Activity activity);

    // 获取活动列表
    @Select("SELECT * FROM activity")
    List<Activity> getAllActivity();

    //通过审核
    @Update("UPDATE activity SET status = #{status} WHERE activityId = #{activityId}")
    boolean updateStatus(
            @Param("activityId") String activityId,
            @Param("status") String status
    );

    // 驳回审核
    @Update("UPDATE activity SET status = #{status}, rejectReason = #{rejectReason} WHERE activityId = #{activityId}")
    boolean rejectStatus(
            @Param("activityId") String activityId,
            @Param("status") String status,
            @Param("rejectReason") String rejectReason
    );

    // 根据状态筛选
    @Select("SELECT * FROM activity WHERE status = #{status}")
    List<Activity> getActivityListByStatus(String status);
}